#include<bits/stdc++.h>
using namespace std;
int main()
{
	int m=0,n=0;
	int num = 0;
	int a[10009] = {0};
	cin >> num;
	int i = 0;
	while(cin >> i)
	{
		a[i]++;
	}
	for(int j = 1; j < 10004; j++)
	{
		if(a[j] >1)
		{
			n = j;
		}
		if(a[j-1] && a[j+1] &&  a[j] == 0)
		{
			m = j;
		}
		if(m&&n)
		{
			break;
		}
	}
	cout<<m<<' '<<n;
	return 0;
}
